<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\api\controller\baiying\Byaiphone;

class Audio extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function detail()
    {
        $request_data = $this->request->param();
        $callInstanceId = empty($request_data['callInstanceId']) ? $request_data['callInstanceld'] : $request_data['callInstanceId'];
        $request_data['callInstanceId'] = $callInstanceId;
        $info = db(getBaiYingDataTable())->where('callInstanceId',$callInstanceId)->find();
        

        $obj = new Byaiphone();
        $detail_info = $obj->signelGetAiTaskPhoneDetail($request_data);
        $chat_list = [];
        if($detail_info['status'] != 4000){
            $detail_info_data = json_decode($detail_info['data'],true);
            $chat_list = $detail_info_data['phoneLogs'];
        }

        if(empty($info)){
            $info = empty($detail_info_data['callInstance']) ? [] : $detail_info_data['callInstance'] ;
        }
        $calljobid = $info['callJobId'];
        $task_name = db('ec_ai_task')->where('callJobId',$calljobid)->value('jobName');
        $info['task_name'] = empty($task_name) ? "未知" : $task_name;
        $info['chat_list'] = $chat_list;
        $this->view->assign('row',$info);
        return $this->view->fetch();
    }
    
    

}

